package com.xbhog.screwdemo.值对象;

import java.util.Objects;

/**
 * @author 衣立君
 * @date 2025/01/04 15:10
 **/
public final class AddressVO {
    private final String street;
    private final String city;
    private final String zipCode;
    private final String country;

    public AddressVO(String street, String city, String zipCode, String country) {
//这里可以添加验证逻辑以确保地址的有效性
        this.street = street;
        this.city = city;
        this.zipCode = zipCode;
        this.country = country;
    }

    //只读访问器
    public String getStreet() {
        return street;
    }

    public String getCity() {
        return city;
    }

    public String getZipCode() {
        return zipCode;
    }

    public String getCountry() {
        return country;
    }

    //重写equals和hashCode方法
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AddressVO address = (AddressVO) o;
        return street.equals(address.street) &&
                city.equals(address.city) &&
                zipCode.equals(address.zipCode) &&
                country.equals(address.country);
    }

    @Override
    public int hashCode() {
        return Objects.hash(street, city, zipCode, country);
    }
}